
from django.contrib import admin
from django.urls import path, re_path, include
from django.conf import settings
from django.conf.urls.static import static
from visualizer.views import network
from django.views.static import serve
import os

urlpatterns = [
    path('admin/', admin.site.urls),
    path('network/', network, name='network'),
    path('', network, name='home'),
    path('vir/', include('vir.urls')),
    re_path(r'^favicon\.ico$', serve, {
        'path': 'visualizer/favicon.ico',
        'document_root': os.path.join(settings.BASE_DIR, 'visualizer', 'static')
    }),
]

if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += [
        # 自定义静态文件服务，禁用缓存
        re_path(r'^static/(?P<path>.*)$', serve, {
            'document_root': settings.STATIC_ROOT,
            'show_indexes': True,
            'cache_control': 'no-cache, max-age=0'
        })
    ]
